<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>报价编辑</title>
<link href="/res/css/respective/priceAsk/buyer.css" rel="stylesheet">
<script src="/res/js/common/jquery.1.9.1.min.js"></script>
</head>
<body>
[#assign menucode="myEnquiry"/]
	<div class="warp">
		[#include "/front/common/front_headAzt.html"]
		<div class="backcontent">
			[#include "/front/common/front_leftAzt.html"]
			[#if enquiry??]
			<div class="back-main">
				<div class="mainContent">
					<div class="mainContentWhite">
						<form>
						<h1>[#if enquiry.qtype == 1]预算[#else]采购[/#if]询价报价详情</h1>
							[#if quote ?? && quote.state == 0 && quote.suggest?? &&  quote.suggest != '']
							<div class="noPassReson">
								<h1>报价审核退回</h1>
								<h2 style="background: none;">您的报价审核未通过，原因：${quote.suggest}（如有疑问，请致电400-848-1365）</h2>
							</div>
							[/#if]
						<hr/>  
							<h2>基本信息</h2>
							<input name="enquiryId" type="hidden" value="${enquiry.id!}"  id="enquiryId"/>
							<input name="taxInstro" type="hidden" value="${enquiry.taxInstro!}" id="taxInstro"/>
							<input name="id" type="hidden" value="${quote.id!}" id="quoteId"/>
							<input name="attachfile" type="hidden" id="attachfile"/>
							<input name="editType" type="hidden" id="editType"/><!--修改的类型 1 重新上传  2 删除item -->
							<input name="totalPrice" type="hidden" id="totalPrice" name="totalPrice"/><!--修改的类型 1 重新上传  2 删除item -->
							<input type="hidden" name="editSpace" id="editSpace" value="[#if quoteItem?? && quoteItem?size > 0 ]2[#else]1[/#if]"/><!-- 1 上传资料 2 清单列表 -->
							<input type="hidden" id="topuPath" value="[#if afArray?? && afArray?size > 1]${afArray[1]}[/#if]"/>
							<input type="hidden" id="solvePath" value="[#if afArray?? && afArray?size > 0]${afArray[0]}[/#if]"/>
							<input name="canQuote" type="hidden" value="1" id="canQuote"/>
							<input name="qtype" type="hidden" value="${enquiry.qtype!}" />
							<div class="baseInfo">
								<div>
									<dfn>
										询价名称：<span class="ellipsis">${enquiry.enquiryName!}</span>
									</dfn>
									<dfn>
										[#assign realCompanyName = '']
										[#if enquiry.ppCompany??]
										[#assign realCompanyName = enquiry.ppCompany!]
										[#elseif enquiry.parentCompany??]
										[#assign realCompanyName = enquiry.parentCompany!]
										[#else]
										[#assign realCompanyName = enquiry.companyName!]
										[/#if]
										发布公司：<span>${myStringUtils.hideCompanyName(realCompanyName)}</span>
									</dfn>
								</div>
								<div>
									<dfn>
										项目名称：<span>${enquiry.projectName!}</span>
									</dfn>
									<dfn>
										质保要求：<span>[#if enquiry.quality??]${enquiry.quality!}年[#elseif enquiry.guaranteeinfo??]${enquiry.guaranteeinfo!}[/#if]</span>
									</dfn>
								</div>
								<div>
									<dfn>
										报价截止时间：<span>${enquiry.deadline?string('yyyy-MM-dd')}</span>
									</dfn>
									<dfn>
										是否含税：
										<span>
											[#if enquiry.taxPrice??]
												[#if enquiry.taxPrice < 3]含税[#if enquiry.taxInstro??]（税率：${enquiry.taxInstro!0}%）[/#if][/#if]
												[#if enquiry.taxPrice==3]不含税[/#if]
											[/#if]
										</span>
									</dfn>
								</div>
								<div>
									<dfn>
										是否含运费：<span>[#if enquiry.shipPrice??]${(enquiry.shipPrice == 1)?string('包含运费' , '不包含运费')}[/#if]</span>
									</dfn>
									<dfn>
										项目所在地：<span>${enquiry.provinceName!}&nbsp;${enquiry.cityName!}</span>
									</dfn>
								</div> 
								<div style="position: relative;">
									[#if enquiry.qtype == 2]
									<dfn>
										支付方式：<span sty>${enquiry.paymentStr!}
										</span>
										[#if enquiry.payment?? && enquiry.payment == 3]<a class="fqDetail" data-type="fqDetail">详情</a>[/#if]
									</dfn> 
									[/#if]
									[#if enquiry.qtype == 1]
									<dfn>
										需要供应商提供：<span>${enquiry.replaceProvideFiles!}</span>
									</dfn> 
									[/#if]
									<div class="fqCont">
										<p class="grayArrow">
											<span class="whiteArrow"> 
											</span>
										</p>
										[#if batchPay??]
											[#list batchPay as bp]
												[#if bp['no']?? && bp['no'] > 0]<hr></hr>[/#if]
												<div>
													<div>
														<em class="qs">第${(bp['no']!0) + 1}期</em>
														<span>付款：</span>
														<em>${bp['per']!}%</em>
													</div>
													<div>
														<span>备注：</span>
														<em class="bzCont">${bp['remark']!}</em>
													</div>
												</div>
											[/#list]
										[/#if]
									</div>
								</div> 
								<div>
									<dfn>
										收货人：<span>****</span>
									</dfn>
									<dfn>
										[#if enquiry.hidePhone?? && enquiry.hidePhone!="" ]联系电话：<span>${enquiry.hidePhone!}</span>[/#if]
									</dfn>
								</div>
								[#if enquiry.qtype == 1 && enquiry.attachfile??]
								<div>
									<dfn style="width: auto;">
										项目资料：<span>&nbsp;&nbsp;<a href="${enquiry.attachfile!}" target="_blank">下载资料</a></span>
									</dfn> 
								</div>
								[/#if]
								[#if enquiry.qtype == 2 && enquiry.attachfile??]
								<div>
									<dfn style="width: auto;">
										[#if enquiry.attachfile?? &&  enquiry.attachfile!="" ]附件：<span>&nbsp;&nbsp;<a href="${enquiry.attachfile!}" target="_blank">下载附件</a></span>[/#if]
									</dfn>
								</div>
								[/#if]
							</div>
							<hr style="margin-bottom: 15px;"> 
							<div class="othNed" [#if !enquiry.otherRemarks?? || enquiry.otherRemarks =='']style="display:none;"[/#if]>
								<label style="color: #999999">其他要求：</label>
								  ${enquiry.otherRemarks!}
							</div> 
							<div class="baseInfo"> 
								<div> 
									[#if enquiry.qtype == 1]
										[#if enquiry.providefiles?? && enquiry.providefiles?contains('2')]
										<dfn>
											<span>*</span>拓扑图：<span>[#if afArray?? && afArray?size > 1]<label title="${afArray[1]!}" onclick="window.open('${afArray[1]!}')" class="pplabel">&nbsp;[@content_cut content=afArray[1] len=35 ending="..."/]&nbsp;</label>[#else]<label></label>[/#if]<a href="javascript:void(0)" id="topuUpload">重新上传</a></span>
										</dfn> 
										[/#if]
										[#if enquiry.providefiles?? && enquiry.providefiles?contains('1')]
										<dfn style="width: auto;">
											<span>*</span>解决方案：<span>[#if afArray?? && afArray?size > 0]<label title="${afArray[0]!}" onclick="window.open('${afArray[0]!}')" class="pplabel">&nbsp;[@content_cut content=afArray[0] len=35 ending="..."/]&nbsp;</label>[#else]<label></label>[/#if]<a href="javascript:void(0)" id="solveUpload">重新上传</a></span>
										</dfn> 
										[/#if]
									[/#if]
								  </div>
							</div>  
						  <h2>报价清单</h2>
						  [#if quoteItem?? && quoteItem?size > 0 ]
						  <div id="itemDiv">
										<table class="table noBorder">
											<thead>
											<tr>
												<th style="width: 15%;">产品类目</th>
												<th style="width: 15%;">商品名称 </th>
												<th style="width: 10%;">品牌</th>
												<th style="width: 10%;">型号</th>
												<th style="width: 10%;">数量</th>
												<th style="width: 10%;">单位</th>
												<th style="width: 10%;">单价</th>
												<th style="width: 10%;">技术参数</th>
												<th style="width: 10%;">删除</th>
											</tr>
											</thead>
											<tbody id="itembody">
											[#list quoteItem as item]
												<tr>
													<input type="hidden" name="itemids"  value="${item.id!}" />
													<td style="width: 15%;">${item.categoryName!}</td>
													<td style="width: 15%;overflow: hidden; word-break: break-all;  text-overflow: ellipsis;" title="${item.productName!}">${item.productName!}</td>
													<td style="width: 10%;">${item.brand!}</td>
													<td style="width: 10%;">${item.model!}</td>
													<td style="width: 10%;" class="quantity">${item.quantity!}</td>
													<td style="width: 10%;">${item.unit!}</td>
													<td style="width: 10%;">￥<label class="unitprice">${item.unitprice!}</label></td>
													<td style="width: 10%;" title="${item.descr!}">[@content_cut content=item.descr! len=20 ending="..."/]</td>
													<td style="width: 10%;" class="del editDel"></td>
												</tr>
											[/#list]
											</tbody>
											<tfoot>
											<tr class="tableBorde">
												<td class="fenye ppTfoot" colspan="9"
													style="background: #f8f8f8; padding:15px;">
													<!--<div style="float: left;">-->
														<!--<dfn>-->
															<!--采购商要求： &nbsp;&nbsp;&nbsp;报价含增税<i>*</i>税点：-->
														<!--</dfn>-->
														<!--<div class="form-controlAzt ppSelect"-->
															 <!--style="width: 120px; display: inline-block; height: 25px;">-->
															<!--<select style="height: 100%; border: none; width: 100%;">-->
																<!--<option>请选择税率</option>-->
															<!--</select>-->
														<!--</div>-->
													<!--</div>-->
													<div style="float: right;">
														<dfn>
															清单总计： &nbsp;&nbsp;&nbsp;<span class="contentBold">${quote.totalPrice!}</span>元
														</dfn>
														<!--<dfn>-->
															<!--优惠价： &nbsp;&nbsp;&nbsp;<input type="text"/>元-->
														<!--</dfn>-->
														<button class="commitButt" type="button" id="goUploadAgain">重新上传</button>
													</div>
												</td>
											</tr>
											</tfoot>
										</table>
									</div>
								 	[/#if]
								 	<div style="text-align: center;">
									<div class="quoteStep"  style="margin: 0px auto;width: 500px;display:block;padding-left: 0;[#if quoteItem?? && quoteItem?size > 0 ]display:none;[/#if]" id="againUpload">
											<div style="padding-right: 15px;">
												<img alt="" src="/res/images/priceAsk/ask14.png"/>
											</div>
											<div style="text-align: left;">
												<h4>已上传：${quote.excelName!}</h4>
												<h5>产品价格填写完毕后，请上传报价清单。</h5>
												<button class="downButt" type="button" onclick="downItem(${enquiry.id!} , ${enquiry.qtype!})" >下载询价清单</button>
												<button class="downButt" type="button" id="fileUpload" >重新上传</button>
												[#if quoteItem?? && quoteItem?size > 0 ]
													<button class="downButt" type="button" id="backToList" >返回清单</button>
												[/#if]
												<input name="excelpath" type="hidden"  id="excelpath" value="${quote.excelpath!}"/>
												<input name="excelName" type="hidden"  id="excelName" value="${quote.excelName!}"/>
											</div>
									</div>
										<div id="quoteList"></div>
									</div>
							</form>
									<div style="text-align: center;overflow: hidden;">
					<hr>
					<button class="commitButt" style="float: right;" type="button" id="saveQuote">提交报价</button>
				</div> 
					</div>   
				</div> 
			</div>
			<!-- 底部菜单-->
			[/#if]
			[#include "/front/common/front_footerAzt.html"]
		</div>
	</div>
<script src="/res/js/common/common.js"></script> 
<script src="/res/third/layer/layer.js"></script>
<script src="/res/third/layer/layer.extends.js"></script>
<script src="/res/third/laydate/laydate.js"></script>
<script src="/res/js/common/jquery.ellipsis.js"></script>
 <script type="text/javascript" >
 $(function(){
	 $(".ellipsis").ellipsis({maxWidth:290,maxLine:1});
		$(".downList").click(function () {
			$(".cantUp").find(".disableButt").hide();
			$(".cantUp").find(".downButt").show();
			$(".cantUp").find("img").attr("src" , "/res/images/priceAsk/ask14.png");
		});

		$("#goUploadAgain").on('click' ,function () {
			$("#itemDiv").hide();
			$("#againUpload").show();
			$("#quoteList").show();
			$('#editSpace').val(1);
		});
		$("#backToList").on('click' ,function () {
			$("#itemDiv").show();
			$("#againUpload").hide();
			$("#quoteList").hide();
			$('#editSpace').val(2);
		});

		$("#fileUpload").on('click' ,function(){
			layer.fileManager({ initType : 'file' ,  callback : function(data){
				if(data.length > 0){
					$("#fileUpload").html("重新上传");
					$("#editType").val(1);
					$("#fileUpload").parent().find("h4").text("上传成功："+data[0].name);
					$("#fileUpload").parent().find("#excelName").val(data[0].name);
					$("#fileUpload").parent().find("#excelpath").val(data[0].url);
					[#if enquiry.qtype == 2]
					//如果是采购询价  则直接就分析
					layer.load(2);
					$("#quoteList").load('/enquiry/analyzeQuote' ,
							{excelPath : data[0].url,excelName : data[0].name ,quoteId : $("#quoteId").val() , enquiryId : $("#enquiryId").val() , projectId : $("#projectId").val()});
					[/#if]
				}
			}});
		});

		$(".editDel").on('click' , function () {
			var $this = $(this);
			if($("#itembody tr").length == 1){layer.alert("不能删除所有清单内容" , {icon:3});return false;}
			var lc = layer.confirm("是否确认删除此列清单内容？" , {icon : 3 , title : "提示"} , function () {
				$this.parent().remove();
				$("#editType").val(2);
				var totalprice = 0;
				$("#itembody tr").each(function(){
					var quantity = Number($(this).find(".quantity").text());
					var unitprice = Number($(this).find(".unitprice").text());
					var ut = (quantity*unitprice);
					totalprice += ut;
				});
				$(".contentBold").text(Number(decimal(decimal(totalprice,6),2)));
				$("#totalPrice").val(Number(decimal(decimal(totalprice,6),2)));
				layer.close(lc);
			});
		});


		$("#saveQuote").on('click' , function(){


			var attPath = [];

			attPath.push($("#solvePath").val());
			attPath.push($("#topuPath").val());

			$("#attachfile").val(attPath.join(";"));


			[#if enquiry.qtype == 2]
				var editType = $("#editType").val();
				if($("#listitembody tr").length == 0 && editType == 1){layer.alert("清单内容不能为空！" , {icon:3});return false;}
			[/#if]



			$.ajax({
				url : '/enquiry/saveQuote' ,
				type : 'post' ,
				dataType : 'json' ,
				data :  $("form").serialize(),
				success : function (data) {
					if(data.success){
						layer.msg("报价[#if enquiry.qtype == 1]提交[/#if]成功！" , {time:2000} , function(){
							location.reload();
						});
					}else{
						layer.msg(data.msg , {time:2000});
					}
				}
			});

		});


		if($("#topuUpload")){
			$("#topuUpload").on('click' ,function(){
				layer.fileManager({callback : function(data){
					if(data.length > 0){
						$("#topuUpload").parent().find("label").html("&nbsp;" + data[0].name+"&nbsp;");
						$("#topuUpload").parent().find("label").attr("title", data[0].name);
						$("#topuUpload").parent().find("label").attr("onclick", "window.open('"+data[0].url+"')");
						$("#topuUpload").parent().find("label").css({"cursor" : "pointer"});
						$("#topuPath").val(data[0].url);
					}
				}});
			});
		}

		if($("#solveUpload")) {
			$("#solveUpload").on('click' ,function(){
				layer.fileManager({initType : 'file' , callback: function (data) {
					if (data.length > 0) {
						$("#solveUpload").parent().find("label").html("&nbsp;" + data[0].name+"&nbsp;");
						$("#solveUpload").parent().find("label").attr("title", data[0].name);
						$("#solveUpload").parent().find("label").attr("onclick", "window.open('"+data[0].url+"')");
						$("#solveUpload").parent().find("label").css({"cursor" : "pointer"});
						$("#solvePath").val(data[0].url);
					}
				}
				});
			});
		}
		$(".baseInfo .fqDetail").hover(function(){ 
			$(".fqCont").show();
		},
		function(){
			$(".fqCont").hide();
		});
	});

//	function downItem(enquiryId){
//		location.href = '/enquiry/exportItem?enquiryId='+enquiryId;
//	}

	 function downItem(enquiryId , qtype){
		 location.href = '/enquiry/exportItem?enquiryId='+enquiryId+"&qtype="+qtype;
	 }

	 //对多位小数进行四舍五入
	 //num是要处理的数字  v为要保留的小数位数
	 function decimal(num,v){
		 var vv = Math.pow(10,v);
		 return Math.round(num*vv)/vv;
	 }
	</script>
</body>
</html>